/**********************************************************************
 * 
 * Name: ContactBirthdaySmsMessage
 * Object: Contact
 * Purpose: 在联系人生日当天发送短信
 * Requirement:
 * Author: kittylau (382376269@qq.com)
 * Create Date: 2017-01-20
 * Modify History: 
 *
 *************************************************************************/
global class ContactBirthdaySmsMessage implements Schedulable {
    global void execute(SchedulableContext sc) {
    	//今天是几月?
    	Integer dmonth = System.today().month();
    	//今天是几号?
    	Integer dday = System.today().day();
    	//取出生日是当天的联系人(手机号不为空)
        List<Contact> cons = [SELECT Id,Name,MobilePhone 
        					  FROM Contact 
        					  WHERE MobilePhone != NULL 
        					  AND Birthdate != NULL 
        					  AND CALENDAR_MONTH(Birthdate) = :dmonth 
        					  AND DAY_IN_MONTH(Birthdate) = :dday];
        System.debug('*** 今天有这些人过生日：' + cons);
        String template = Utils.getSMSTemplate('生日祝福');
        for(Contact con : cons){
        	Utils.sendSmsMessage(con.MobilePhone, template.replace('{ContactName}', con.Name));
        }
    }
}